/*******************************************************************************
 * NMMEditor - WYSIWYG HTML Editor for Internet Copyright (C) 2013- kindsoft.net
 * 
 * @author topin
 * @licence GNU V3 GPL 高低音
 ******************************************************************************/
KindEditor.plugin('HL', function(K) {
	console.debug("HL start");
	var self = this, name = 'HL', lang = self.lang(name + '.');
	var count = 0;
	self.plugin.HL = {
		add : function() {
			console.info(count);
			count++;
			return count;
		},
		edit : function() {
			console.clear();
			console.dir(self);
			//console.dir(K.extend);
			console.debug("HL edit");
			//console.debug(self.cmd.range.startOffset);
			//var cmd = K.cmd(self);
			//console.info(cmd.bold());
			//self.cmd.bold();
			console.info(self.selectedHtml());
			//工具栏的选择
			//console.log(self.cmd.state(name));
			if(self.cmd.state(name)){
				self.toolbar.unselect(name);
				console.log("if "+self.cmd.state(name));
			}else{
				self.toolbar.select(name);				
				console.log("else "+self.cmd.state(name));
			}
			//self.cmd.toggle('<strong></strong>', { span : '.font-weight=bold', strong : '*', b : '*' });
			//K(self.selectedHtml());
			var node = K("<div></div>").addClass("gray");
			var count = self.plugin.HL.add();
			//self.insertHtml("<span class=\"dbUnderLine\">Try it yourself »</span>");
			
			//增加倍高音
			//self.cmd.wrap('<udb></udb>');
			self.cmd.toggle('<udb></udb>',{udb : '*'});
			//self.cmd.wrap('<strong></strong>');
			//K(self.selectedHtml()).addClass("gray");
			//self.cmd.toggle(node, { span : '.font-weight=div', div :"*", b: "*"});
			
			//K("div").attr('cla', 'hehe').html("aaa");
			//console.dir(K("div"));
			//console.info(K(self.selectedHtml()).attr('cla', 'hehe').html("aaa").html());
		}
	};
	self.clickToolbar(name, self.plugin.HL.edit);
});
